package second;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class WorkerTest {
    public static void main(String[] args) {
        List list = new ArrayList();
        Worker worker01 = new Worker("凤姐",18,20000);
        Worker worker02 = new Worker("欧阳锋",60,8000);
        Worker worker03 = new Worker("刘德华",40,30000);
        System.out.println("worker03 =  "+System.identityHashCode(worker03));
        list.add(worker01);
        list.add(worker02);
        list.add(worker03);
        System.out.println("数组内容是1: "+Arrays.asList(list));
        list.add(1,new Worker("张柏芝",35,3300));
        System.out.println("数组内容是2: "+Arrays.asList(list));
        Worker worker04 = new Worker("刘德华",40,30000);
        System.out.println("worker04 = "+System.identityHashCode(worker04));

        list.remove(worker04);
        System.out.println("数组内容是3: "+Arrays.asList(list));

        for (Object i:list) {
            Worker work = (Worker)i;
            System.out.println(work);
        }
        Iterator it1 = list.iterator();
        while (it1.hasNext()){
            Worker work = (Worker)it1.next();
            System.out.println("222"+work);
        }
        System.out.println(worker04.equals(worker03));
    }
}
